package com.itheima.stock.controller;

import com.itheima.stock.common.domian.PermissionDomain;
import com.itheima.stock.pojo.SysPermission;
import com.itheima.stock.service.PermissionService;
import com.itheima.stock.vo.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * @author: siwukun
 * @date: 2022/06/10
 * @description: 权限管理
 */
@RestController
@RequestMapping("/api")
public class PermissionController {
    @Autowired
    private PermissionService permissionService;

    /**
     * 查询所有权限列表
     * @return
     */
    @GetMapping("/permissions")
    public R<List<SysPermission>> getAllPermissions(){
        return permissionService.getAllPermissions();
    }

    /**
     * 添加权限时回显权限树
     * @return
     */
    @GetMapping("/permissions/tree")
    public R<List<PermissionDomain>> getPermissionTree(){
        return permissionService.getPermissionTree();
    }

}
